import com.unipay.spring.proxy.Calculator;
import com.unipay.spring.proxy.CalculatorImpl;
import com.unipay.spring.proxy.ProxyFactory;
import org.junit.Test;

/**
 * @BelongsProject: SSM
 * @Author: cmy
 * @CreateTime: 2023-01-17  10:18
 * @Description: TODO
 */

public class DynProxy {

    @Test
    public void testDynamicProxy(){
        ProxyFactory proxyFactory = new ProxyFactory(new CalculatorImpl());
        // 不知道具体怎么做的。但是，通过向上转型，获取接口的对象
        Calculator proxy = (Calculator) proxyFactory.getProxy();
        proxy.add(2, 3);

        System.out.println("----------------");
        proxy.div(1, 0);
    }
}
